<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateTableAdmin extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $this->execute("CREATE TABLE `f_admin` (
            `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
            `username` varchar(60) DEFAULT NULL COMMENT '用户名',
            `password` varchar(128) DEFAULT NULL COMMENT '密码',
            `salt` varchar(6) DEFAULT NULL COMMENT '密码盐',
            `role` varchar(45) DEFAULT 'normal' COMMENT '角色名称',
            `email` varchar(45) DEFAULT NULL COMMENT '电子邮件',
            `mobile` varchar(45) DEFAULT NULL COMMENT '手机号码',
            `department` varchar(45) DEFAULT NULL COMMENT '所属部门',
            `lastlogin_time` int(11) DEFAULT NULL COMMENT '上次登陆时间',
            `avatar` varchar(145) DEFAULT NULL COMMENT '头像路径',
            `truename` varchar(45) DEFAULT NULL COMMENT '真实姓名',
            `area` varchar(45) DEFAULT NULL,
            `status` varchar(45) DEFAULT 'normal',
            `creator` int(10) unsigned DEFAULT NULL,
            `create_time` int(11) DEFAULT NULL COMMENT '创建时间戳',
            `update_time` int(11) DEFAULT NULL COMMENT '更新时间戳',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理系统管理员表';");
    }
    public function down()
    {
        $this->execute("drop table `f_admin`;");
    }
}
